<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
    </style>

</head>

<body>
    <div id="root">
        <textarea v-model="liuyan"></textarea><button @click="addliuyan">发布</button>
        <ul>
            <li v-for="(item, index) in newliuyan" :key="index">{{item}} <button @click="remove(index)"> 删除</button>
                <hr>
            </li>
        </ul>
    </div>

    <script>
        new Vue({
            el: '#root',
            data() {
                return {
                    liuyan: '',
                    newliuyan: []
                }
            },
            methods: {
                addliuyan() {
                    this.newliuyan.unshift(this.liuyan)
                    this.liuyan = ''
                },
                remove(index) {
                    this.newliuyan.splice(index, 1);
                },
            },
        })
    </script>
</body>

</html>